Skip to content

fix: repair failing tests and type errors across api and shared packages - #113

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2171-1785256672
Open

fix: repair failing tests and type errors across api and shared packages#113
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2171-1785256672

Conversation

@stooit

@stooit stooit commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors across the api and shared packages. Final state: bun test22 pass / 0 fail; bunx tsc --noEmitexit 0.

Changes

  • shared/types: renamed User.userNameusername to align the shared type with its consumers and the test contract (was causing tsc errors in routes/users.ts and the users tests).
  • shared/pagination: implemented the paginate() stub (previously threw not implemented) — 1-based paging with slice-based windowing, correct total/totalPages, and empty data for out-of-range pages.
  • api/auth middleware: fixed HTTP method case in the public-route allow-list (postPOST) so POST /users is correctly treated as public (no token required).
  • api/routes/users: added the missing badRequest import so 400 responses for missing fields resolve at runtime.
  • tsconfig: added bun-types to compilerOptions.types to resolve the bun:test module and process globals (uses an already-present dependency; no new deps added).

Verification

bun test          → 22 pass, 0 fail, 37 expect() calls
bunx tsc --noEmit → exit 0

Assumptions

  • Field name: tests and route consumers expect username, so the shared type was changed to match (rather than editing tests).
  • Pagination is 1-based, matching the test expectations.
  • The bun:test/process tsc errors were a tsconfig wiring gap (missing bun-types in types), not a missing dependency — resolved via config only.

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Only source needed to satisfy the tests was changed.

- shared: rename User.userName -> username to match consumers and tests
- shared: implement paginate() utility (1-based paging, slice-based)
- api/auth: fix HTTP method case (post -> POST) so POST /users is public
- api/users: add missing badRequest import for 400 responses
- tsconfig: add bun-types to compilerOptions.types for bun:test resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant